package com.javase.comparator;

import java.util.Comparator;

public class CompareByLength implements Comparator<String> {

    @Override
    public int compare(String o1, String o2) {
        return o1.length() == o2.length() ? o2.compareTo(o1) : o2.length() - o1.length();
    }
}
